package sp.user;

import org.junit.Test;

import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException;

import sp.pojo.User;
import sp.service.UserService;
import sp.util.SpringUtil;
import sp.util.mail.MailUtils;

public class testEmail {

	
	@Test
	public void testSendEmail() {
		UserService service = (UserService) SpringUtil.getBean("userService");
		
		User user = new User();
		user.setTypeCode("458028166@qq.com");
		user.setPassword("test");
		try {
			service.txsaveUser(user);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			SpringUtil.close();
		}
	}
	

	@Test
	public void testEmailutil() throws MessagingException, javax.mail.MessagingException{
		String emailMsg = "<html><head></head><body><p>您好 O(∩_∩)O~~<br><br>欢迎您使用淘书!<br>"
				+ "<h1>请在30分钟内点击以下链接激活注册账号</h1><h3>"
				+ "<a href='http://localhost:8888/SecondPlatform/sp/email-active.action?email=" + "458028166@qq.com" + "&activecode=456'>"
						+ "http://localhost:8888/SecondPlatform/sp/email-active.action?email=" + "458028166@qq.com" + "&activecode=456</a></h3></body></html>";
		MailUtils.sendMail("458028166@qq.com", emailMsg);
	}
	
}
